//引入代码
import request from './request';
import requestUser from './requestUser';
module.exports = {
  /**
   * 用户登陆
   */
  login: (code) => {
    return request({
      url: `/common/account/wx/auth/${code}`,
      method: 'POST'
    });
  },

  /**
   * 保存用户信息
   * 
   */
  saveUserInfo: (data) => {
    return request({
      url: `/member/account/wx/saveOrUpdate/info`,
      method: 'POST',
      data: data
    })
  },
  /**
   * 弹出广告
   * 
   */
  popAds: (city) => {
  var  city = encodeURI(city);
    return request({
      url: `/member/advertisement/pop/ad?city=${city}`,
      method: 'POST',
    });
  },
  // 点击广告接口
  clickAds: (id) => {
    return request({
      url: `/member/advertisement/click/ad?advertisementId=${id}`,
      method: 'POST',
    });
  },
// 扫码进入店铺
  intoShop: (data) => {
    return request({
      // url: `/member/advertisement/intoShop`,
      url: `/member/advertisement/intoShop?shareRecordId=${data.shareRecordId}&advertisementId=${data.advertisementId}`,
      method: 'POST',
      // params: data,
    });
  },
//微信用户点击分享生成分享店铺小程序码
  // clickShareMakeMini: (data) =>{
  //   return request({
  //     url: `/member/advertisement/?`,
  //     method: 'POST',
  //     params: data,
  //   });
  // },
  


  /**
   * 首页加载
   */

  // 加载轮播图数据
  loadIndexBanner: (data) => {
    return request({
      url: `/common/banner/search`,
      method: 'POST',
      data: data
    })
  },

  //首页分类列表数据
  loadIndexSort: (data) => {
    data.city = encodeURI(data.city);
    return request({
      url: `/common/shop/category/search`,
      method: 'GET',
      params: data,
    });
  },

  //首页精选店铺
  selectedData: (data) => {
    data.city = encodeURI(data.city);
    return request({
      url: `/common/shop/search/selected`,
      method: 'GET',
      params: data,
    });
  },

  //查询促销标签以及其店铺
  getHotData: (data) => {
    data.city = encodeURI(data.city);
    return request({
      url: `/common/promotion/tag/search/shops`,
      method: 'POST',
      params: data,
    });
  },

  //查看更多商品
  moreShop(page, size, city) {
    city = encodeURI(city);
    return request({
      url: `/common/newest/search/more/${page}/${size}?city=${city}`,
      method: 'GET',
    });
  },

  //店铺点击有钱赚
  clickMerchantDto(data) {
    return request({
      url: `/member/click/getMoney`,
      method: 'POST',
      data: data
    });
  },


  /**
   * 购物车管理
   */

  // 查询购物车
  searchCart: () => {
    return request({
      url: `/member/shop/cart/search`,
      method: 'GET'
    })
  },
  //删除购物车
  delGoods: (data) => {
    return request({
      url: `/member/shop/cart/delete`,
      method: 'POST',
      params: data
    })
  },

  /**
   * 拼团管理
   * 
   */
  //查询拼团模板
  searchSpell: (page, size, data) => {
    return request({
      url: `/common/spell/template/merchant/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },

  /**
   * 获取附近店铺列表
   * 
   */
  getNearby: (data) => {
    return request({
      url: `/common/shop/search/near/by`,
      method: 'POST',
      data: data
    })
  },

  /**
   * 分类管理
   * 
   */
  //人气商家店铺
  getPopularityShop: (data, page, size) => {
    return request({
      url: `/common/shop/search/visit/category/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },
  //附近商家店铺
  getNearbyShop: (data, page, size) => {
    return request({
      url: `/common/shop/search/near/by/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },
  //查看搜索分类信息
  getSearchSort: (data) => {
    return request({
      url: `/common/shop/search/by/name`,
      method: 'POST',
      data: data
    })
  },

  /**
   * 店铺管理
   */

  //店铺基本信息
  getShopInfo: (id) => {
    return request({
      url: `/common/shop/search/one/${id}`,
      method: 'GET',
    })
  },
  //查询店铺轮播
  getShopBanner: (id) => {
    return request({
      url: `/common/shop/banner/search/${id}`,
      method: 'GET',
    })
  },
  //查询店铺商品分类
  getShopGoodsSort: (id) => {
    return request({
      url: `/common/newest/category/search/${id}`,
      method: 'GET',
    })
  },
  //店铺分类商品数据信息
  getGoodsList: (categoryId, type) => {
    return request({
      url: `/common/newest/search/by/${categoryId}/${type}`,
      method: 'GET',
    })
  },

  //商品详情页信息数据  
  getGoodsDetailInfo: (id) => {
    return request({
      url: `/common/newest/one/${id}`,
      method: 'GET',
    })
  },

  //获取店铺的小程序码
  shopCode: (id) => {
    return request({
      url: `/member/shop/share/search/code/${id} `,
      method: 'POST',
    })
  },
  //分享者获取奖励
  shareUser(shopShareRecordId) {
    return request({
      url: `/member/shop/share/draw/share/reward/${shopShareRecordId} `,
      method: 'POST',
    })
  },

  //根据分享id来查询店铺id
  shareShopId(shopShareRecordId) {
    return request({
      url: `/member/shop/share/search/shopId/${shopShareRecordId}`,
      method: 'GET',
    })
  },

  /**
   * 收藏管理
   * 
   */
  //查看是否收藏 
  isCollData: (id) => {
    return request({
      url: `/member/shop/collection/is/collection/${id}`,
      method: 'POST',
    })
  },

  //添加收藏
  addColl: (id) => {
    return request({
      url: `/member/shop/collection/create/${id}`,
      method: 'POST',
    })
  },
  //取消收藏
  delColl: (id) => {
    return request({
      url: `/member/shop/collection/cancel/${id}`,
      method: 'POST',
    })
  },
  //查询收藏店铺
  queryCollShop: (data, page, size) => {
    return request({
      url: `/member/shop/collection/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },


  /**
   * 购物车管理
   * 
   */
  //添加购物车
  addCart: (id, num) => {
    return request({
      url: `/member/shop/cart/add/${id}/${num}`,
      method: 'POST',
    })
  },
  //查询购物车
  queryCart: () => {
    return request({
      url: `/member/shop/cart/search`,
      method: 'GET',
    })
  },

  /**
   * 拼团秒杀管理
   * 
   */
  //拼团秒杀详情页
  spellDetail: (id) => {
    return request({
      url: `/common/spell/template/one/${id}`,
      method: 'GET',
    })
  },
  //查询拼团队伍
  querySpellList: (id, page, size) => {
    return request({
      url: `/common/task/search/${id}/${page}/${size}`,
      method: 'GET',
    })
  },

  /**
   * 优惠券管理
   * 
   */
  //用户红包
  getRecord: (data, page, size) => {
    return request({
      url: `/member/coupon/record/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },
  //店铺红包
  getShopRecord: (data, page, size) => {
    return request({
      url: `/common/coupon/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },
  //领取红包
  getPrice(id) {
    return request({
      url: `/member/coupon/record/draw/${id}`,
      method: 'POST',
    })
  },
  //订单红包列表
  redOrderData(shopId, orderPrice) {
    return request({
      url: `/member/coupon/record/can/use/${shopId}?orderPrice=${orderPrice}`,
      method: 'POST',
    })
  },

  /**
   * 地址管理
   */
  //新建收货地址
  newAddress: (data) => {
    return request({
      url: `/member/receiveAddress/add`,
      method: 'POST',
      data: data
    })
  },

  //查询收货地址列表
  queryAllAddress: () => {
    return request({
      url: `/member/receiveAddress/search`,
      method: 'GET',
    })
  },

  //删除收货地址
  delAddress: (id) => {
    return request({
      url: `/member/receiveAddress/delete/${id}`,
      method: 'POST',
    })
  },

  //设置默认地址
  defaultAddress: (id) => {
    return request({
      url: `/member/receiveAddress/update/default/${id}`,
      method: 'POST',
    })
  },

  //根据id查看对应地址信息
  queryAddressId: (id) => {
    return request({
      url: `/member/receiveAddress/search/one/${id}`,
      method: 'GET',
    })
  },
  //修改地址
  eidtAddress: (data) => {
    return request({
      url: `/member/receiveAddress/update`,
      method: 'POST',
      data: data
    })
  },
  //获取默认收货地址
  getDefaultAddress: () => {
    return request({
      url: `/member/receiveAddress/search/default`,
      method: 'GET',
    })
  },

  /**
   * 订单管理
   * 
   */

  //创建普通订单
  createOrder: (data) => {
    return request({
      url: `/member/common/order/create`,
      method: 'POST',
      data: data
    })
  },
  //创建拼团和秒杀订单
  createSpellOrder: (data) => {
    return request({
      url: `/member/task/create`,
      method: 'POST',
      data: data
    })
  },

  //预览普通订单信息
  ordinaryOrderInfo: (data) => {
    return request({
      url: `/member/common/order/pre`,
      method: 'POST',
      data: data
    })
  },

  //订单商品数量查询
  queryGoodsNum: (data) => {
    return request({
      url: `/member/shop/cart/search/pay/info`,
      method: 'POST',
      data: data
    })
  },

  //查询订单
  queryOrder: (data, page, size) => {
    return request({
      url: `/member/order/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },

  //取消订单
  cancelOrder: (orderId) => {
    return request({
      url: `/member/order/refund/${orderId}`,
      method: 'POST',
    })
  },
  //待付款订单继续支付
  payOrder: (orderId) => {
    return request({
      url: `/member/order/continue/pay/${orderId}`,
      method: 'POST',
    })
  },
  //确认订单
  confirmOrder: (orderId) => {
    return request({
      url: `/member/order/confirmReceiveOrder/${orderId}`,
      method: 'POST',
    })
  },

  //拼团秒杀预览
  spellOrderInfo: (data) => {
    return request({
      url: `/member/task/pre`,
      method: 'POST',
      data: data
    })
  },

  /**
   * 产品发布商家入住管理
   * 
   */
  //商家入住提交信息
  getBusinessmenInfo(data) {
    return request({
      url: `/public/openplatform/bigcustomer/applications/str`,
      method: 'POST',
      data: data
    })
  },

  //商户查询店铺
  searchShop(data, page, size) {
    return requestUser({
      url: `/merchant/retail/shop/search/${page}/${size}`,
      method: 'POST',
      data: data,
    })
  },

  //管理员登录
  userLogin(data) {
    return request({
      url: `/common/account/login/admin`,
      method: 'POST',
      data: data,
      refresh_token: true,
    })
  },

  //获取手机验证码
  sendCheckCode(phone) {
    return request({
      url: `/common/account/send/update/pass/check/code/${phone}`,
      method: 'POST',
    })
  },
  //修改密码
  updatePass(data) {
    return request({
      url: `/common/account/update/pass`,
      method: 'POST',
      data: data,
    })
  },

  //查询商户订单列表 merchant
  queryMerchant(data, page, size) {
    return requestUser({
      url: `/merchant/order/search/${page}/${size}`,
      method: 'POST',
      data: data,
    })
  },

  //查询代理商订单接口
  queryAgent(data, page, size) {
    return requestUser({
      url: `/agent/order/search/${page}/${size}`,
      method: 'POST',
      data: data,
    })
  },

  //待发货
  seedGoods(data) {
    return requestUser({
      url: `/agent/order/hand/send`,
      method: 'POST',
      data: data
    })
  },

  //查询物流公司
  queryLogistics(page, size, name) {
    if (!name) {
      name = ''
    }
    return requestUser({
      url: `/common/post/search/${page}/${size}?name=${name}`,
      method: 'GET'
    })
  },

  //扫码核销订单(自提,到店消费)
  scannerOrder(orderCode) {
    return requestUser({
      url: `/agent/order/handler/zt/consume/${orderCode}`,
      method: 'POST'
    })
  },

  //红包核销
  scannerRedPage(shopId, key) {
    return requestUser({
      url: `/member/coupon/record/convert/${shopId}?key=${key}`,
      method: 'POST',
    })
  },

  //查询商户壹配送大商户TOKEN
  merchantId() {
    return requestUser({
      url: `/merchant/account/access`,
      method: 'GET',
    })
  },

  //获取代理商id
  agentId() {
    return requestUser({
      url: `/agent/account/access`,
      method: 'GET',
    })
  },

  //关联壹配送订单
  linkOrder(data) {
    return requestUser({
      url: `/agent/order/import/yps`,
      method: 'POST',
      data: data
    })
  },



  //判断是否展示产品发布信息
  isProductRelease() {
    return request({
      url: `/common/account/settled/in/flag`,
      method: 'GET',
    })
  },



  /**
   * 银行卡管理
   * 
   */

  //查询全部银行卡
  queryBankCard() {
    return request({
      url: `/super/bank/search`,
      method: 'GET',
    })
  },

  //删除银行卡
  delBankCard(bankId) {
    return request({
      url: `/super/bank/delete/${bankId}`,
      method: 'POST',
    })
  },

  //绑定银行卡
  bindBankCard(data) {
    return request({
      url: `/super/bank/bind`,
      method: 'POST',
      data: data,
    })
  },

  //提交提现申请
  cashOut(data) {
    return request({
      url: `/agent/draw/application/create`,
      method: 'POST',
      data: data,
    })
  },

  //查询用户的余额信息
  queryUserMoney() {
    return request({
      url: `/member/finance/search/one`,
      method: 'POST',
    })
  },

  //查询记录
  queryAraw(data, page, size) {
    return request({
      url: `/agent/draw/application/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },

  //微信公众号登陆
  // wxgzhLogin(code,id){
  //   return requestUser({
  //     url: `/api/common/wx/bind/merchant?code=${code}&state=${id}`,
  //     method: 'POST',
  //     data: data
  //   })
  // },


  //查询账单支付记录
  queryBillPayStatus(billId) {
    return request({
      url: `/merchant/expend/polling/${billId}`,
      method: 'GET',
    })
  },

  //搜索
  searchOpenCity(billId) {
    return request({
      url: `/common/shop/category/search/already/exist`,
      method: 'GET',
    })
  },
  //查询商品评论
  queryGoodsComment(page, size, data) {
    return request({
      url: `/member/comment/search/${page}/${size}`,
      method: 'POST',
      data: data
    })
  },
  //评论点赞
  commentThumbsUp(commentId) {
    return request({
      url: `/member/comment/thumbs/up/${commentId}`,
      method: 'POST',
    })
  },
  //查询评论回复
  queryCommentReply(commentId, page, size) {
    return request({
      url: `/member/comment/search/one/comment/${commentId}/${page}/${size}`,
      method: 'POST',
    })
  },
  //查询评价详情
  queryCommentDesc(commentId) {
    return request({
      url: `/member/comment/search/one/${commentId}`,
      method: 'GET',
    })
  },
  //回复点赞或者取消点赞
  replyThumbsUp(replyId) {
    return request({
      url: `/member/comment/reply/thumbs/up/${replyId}`,
      method: 'POST',
    })
  },
  //提交评论
  sbumitReply(data) {
    return request({
      url: `/member/comment/reply`,
      method: 'POST',
      data: data
    })
  },
  //通用上传文件的方法
  upload(data) {
    return request({
      url: `/common/file/upload`,
      method: 'POST',
      data: data
    })
  },
  //提交订单评论
  submitComment(data) {
    return request({
      url: `/member/comment/submit`,
      method: 'POST',
      data: data
    })
  },
  //查询最后最后一次购物车的店铺
  lastAddCartShop(data) {
    return request({
      url: `/member/shop/cart/find/last`,
      method: 'GET'
    })
  },
  //查询是否已收藏该商品
  isGoodsCollection(goodsId) {
    return request({
      url: `/member/collection/goods/${goodsId}`,
      method: 'GET'
    })
  },
  //收藏商品
  goodsCollection(goodsId) {
    return request({
      url: `/member/collection/goods/add/${goodsId}`,
      method: 'POST'
    })
  },
  //取消收藏商品
  cancelGoodsCollection(goodsId) {
    return request({
      url: `/member/collection/goods/cancel/${goodsId}`,
      method: 'POST'
    })
  },
  //查询商品收藏
  searchGoodsCollection(page,size,data){
    return request({
      url: `/member/collection/goods/search/${page}/${size}`,
      method: 'POST',
      data,data
    })
  },
}